﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;
using System.Data;
namespace DataAccess
{
   public  class KhachHang_Info
    {
       public string makhachhang { get; set; }
       public string hovaten { get; set; }
       public int socmnd { get; set; }
       public string passport { get; set; }
       public string email { get; set; }
       public string sodienthoai { get; set; }
       public string diachi { get; set; }
       public string coquan { get; set; }
       public bool gioitinh { get; set; }
       public static DataSet GetAll()
       {
           try
           {
               return DataProvider.Instance.ExecuteDataset("KhachHang_GetAll");
           }
           catch (Exception)
           {

               return null;
           }
       }
       public static DataSet Search(string name)
       {
           try
           {
               return DataProvider.Instance.ExecuteDataset("KhachHang_GetByName",name);
           }
           catch (Exception)
           {

               return null;
           }
       }
       public static bool Add(string makh, string hovaten, int cmnd, string passport, string email, string sodienthoai, string diachi, string coquan,bool gioitinh)
       {
           try
           {
               object rs = DataProvider.Instance.ExecuteNonQuery("KhachHang_Insert", makh, hovaten, cmnd, passport, email,sodienthoai, diachi,coquan, gioitinh);
               return Convert.ToInt32(rs) > 0;
           }
           catch (Exception e)
           {
               return BatLoi.ThongBao(e.Message);
           }
       }
       public static bool Update(string manv, string hovaten, int cmnd, string passport, string email, string sodienthoai, string diachi, string coquan, bool gioitinh)
       {
           try
           {
               object rs = DataProvider.Instance.ExecuteNonQuery("KhachHang_Update", manv, hovaten, cmnd, passport, email, sodienthoai, diachi, coquan, gioitinh);
               return Convert.ToInt32(rs) > 0;
           }
           catch (Exception)
           {

               return false;
           }
       }

       public static bool Delete(string makhachhang)
       {
           try
           {
               int rs = DataProvider.Instance.ExecuteNonQuery("KhachHang_Delete", makhachhang);
               return rs > 0;
           }
           catch (Exception)
           {

               return false;
           }
       }
       //public static List<KhachHang_Info> GetByID(string makh)
       //{
       //    try
       //    {
       //        return CBO.FillCollection<KhachHang_Info>(DataProvider.Instance.ExecuteReader("KhachHang_GetByID", makh));
       //    }
       //    catch
       //    {
       //        return null;
       //    }
       //}
       public static DataSet GetByID(string makh)
       {
           try
           {
               return DataProvider.Instance.ExecuteDataset("KhachHang_GetByID", makh);
           }
           catch
           {
               return null;
           }
       }
    }

}
